#include <my_head.h>

int main(int argc, const char *argv[]){
    time_t sec = 0;
    if(-1 == time(&sec))
        ERR_LOG("time error");
    printf("sec = %ld\n", sec);

    struct tm *p = NULL;
    if(NULL == (p = localtime(&sec)))
        ERR_LOG("localtime error");
    printf("%04d-%02d-%02d %02d:%02d:%02d\n",\
            p->tm_year + 1900, p->tm_mon + 1, p->tm_mday, \
            p->tm_hour, p->tm_min, p->tm_sec);
    // 使用下面的用法 可以将信息写入文件中
    // fprintf(fp, "%04d-%02d-%02d %02d:%02d:%02d\n",\
        p->tm_year + 1900, p->tm_mon + 1, p->tm_mday, \
        p->tm_hour, p->tm_min, p->tm_sec);
    
    return 0;
}